package com.yuexunit.finance.project.service;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.project.entity.FinanceConstractCallBackInfoEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.page.PageCriteria;
import com.yuexunit.page.PageList;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.persist.annotation.Transactional;

/**
 * @author wenwenlong
 */
@Implements(FinanceConstractCallBackService.class)
public class FinanceConstractCallBackServiceImpl implements FinanceConstractCallBackService {

	@Override
	@Transactional
	public Long createAbnormalBlame(FinanceConstractCallBackInfoEntity entity) {
		PersistUtil.insert(entity);
		return entity.getCallBackId();
	}
	
	@Override
	public FinanceConstractCallBackInfoEntity inquireCallBackInfoDetail(Long callBackId) {
		return PersistUtil.get(FinanceConstractCallBackInfoEntity.class, callBackId);
	}

	@Override
	public PageList<FinanceConstractCallBackInfoEntity> inquireCallBackInfoPageList(Long financeId, PageCriteria page) {
		DetachedCriteria criteria = DetachedCriteria.forClass(FinanceConstractCallBackInfoEntity.class);
		if (financeId != null) {
			criteria.add(Restrictions.eq("financeId", financeId));
		}
		criteria.addOrder(Order.desc("callBackDateTime"));
		return PersistUtil.get(criteria, page);
	}
}
